<?php #//v.3.3.0

class HTMLPurifier {

 var $text;
 var $allowed_tags;
 /*
  * Constructor
  */
  function HTMLPurifier()
   {
     $this->text = "";
	 $this->allowed_tags = array ( 'a', 'p' );
   }

  function allowed_tags ( $allowed_tags )
  {
   $this->allowed_tags =  $allowed_tags; 
  }

  function purify ( $string )
	{
        $string = strtolower(rawurldecode($string));
        preg_match_all('!<\s*(/)?\s*([a-zA-Z0-9]+)[^>]*>!', $string, $all_tags);
        array_shift($all_tags);
        $slashes = $all_tags[0];
        $all_tags = $all_tags[1];
        foreach ($all_tags as $i => $tag)
            if (!in_array($tag, $this->allowed_tags))
                $string = preg_replace('!<(\s*'.$slashes[$i].'\s*'.$tag.'[^>]*)>!', '&lt;'.'$1'.'&gt;', $string);

     return $string;     
	}

}

?>